package com.snow.useviewdemo.util;

import android.os.Handler;
import android.os.Looper;

/**
 * Created by zhaoyingtao
 * Date: 2020/7/14
 * Describe:项目使用Handler管理类==避免项目不断创建handler造成内存泄漏
 * 1、快速实现子线程运行到主线程
 * 2、延时执行某操作
 */
public class HandlerHelper {
    private static Handler sHandler = new Handler(Looper.getMainLooper());

    public static void post(Runnable runnable) {
        if (sHandler != null && runnable != null) {
            sHandler.post(runnable);
        }
    }

    public static void postDelay(Runnable runnable, long delayTime) {
        if (sHandler != null && runnable != null) {
            sHandler.postDelayed(runnable, delayTime);
        }
    }
}
